//
//  HomeRecommendCell.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/11/20.
//  Copyright © 2018年 guoshikeji. All rights reserved.
//

#import "HomeRecommendCell.h"

//
#import "CustomProjectSmallContentView.h"

@interface HomeRecommendCell ()

@property (nonatomic, strong) CustomProjectSmallContentView *customContentView;

@end

@implementation HomeRecommendCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupSubviews];
    }
    return self;
}

- (void)setupSubviews {
    self.customContentView = [CustomProjectSmallContentView new];
    [self.contentView addSubview:self.customContentView];
    [self.customContentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self.contentView);
    }];
    //
    [self addSubview:self.separatorLine];
    [self.separatorLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self);
        make.centerX.mas_equalTo(self);
        make.width.mas_equalTo(self).offset(-20.0);
        make.height.mas_equalTo(1.0);
    }];
    
    
    UITapGestureRecognizer *tapCollection = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapCollectionAction)];
    [self.customContentView.displayCollection addGestureRecognizer:tapCollection];
}


#pragma mark - tapCollectionAction
- (void)tapCollectionAction {
    if (self.tableView) {
        if (self.tableView.delegate && [self.tableView.delegate respondsToSelector:@selector(tableView:didSelectRowAtIndexPath:)]) {
            [self.tableView.delegate tableView:self.tableView didSelectRowAtIndexPath:[self.tableView indexPathForCell:self]];
        }
    }
}

- (void)setCellData:(BCProjectModel *)cellData {
    _cellData = cellData;
    //
    self.customContentView.contentData = cellData;
}


//- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
//    [super setHighlighted:highlighted animated:animated];
//    //
//    if (highlighted) {
//        [self.contentView.layer removeAllAnimations];
//        CATransition *transition = [[CATransition alloc] init];
//        transition.type = @"rippleEffect";
//        //        transition.subtype = kCATransitionFromRight;
//        transition.duration = 0.6;
//        transition.repeatCount = 1;
//        transition.removedOnCompletion = true;
//        [self.contentView.layer addAnimation:transition forKey:@""];
//    }
//}

+ (CGFloat)defaultHeight {
    return 135.0f;
}

@end
